/* AdministratorController.java
 *
 * Copyright (C) 2013 Universidad de Sevilla
 * 
 * The use of this project is hereby constrained to the conditions of the 
 * TDG Licence, a copy of which you may download from 
 * http://www.tdg-seville.info/License.html
 * 
 */

package controllers;

import java.util.Collection;
import java.util.HashSet;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import services.ActorService;
import services.ProjectService;
import domain.Project;

@Controller
@RequestMapping("/project")
public class ProjectController extends AbstractController {

	//Services -----------------------------------------------------------------
	
	@Autowired
	ProjectService projectService;
	
	@Autowired
	ActorService actorService;

	
	// Constructors -----------------------------------------------------------
	
	public ProjectController() {
		super();
	}
		
	// list ---------------------------------------------------------------		

	@RequestMapping("/list")
	public ModelAndView list() {
		ModelAndView result;
		Collection<Project> unfinishedProjects;
			
		try{
			unfinishedProjects = projectService.findNonFinishedProjects();	
		}
		catch (Exception e) {
			unfinishedProjects= new HashSet<Project>();
		}
		
		result = new ModelAndView("project/list");
		result.addObject("projects", unfinishedProjects);
		result.addObject("URI", "/project/list.do");
		return result;
	}
	
	
}